import Vuex from 'vuex'
import Vue from 'vue'
import {getItem,setItem} from "@/utils/storage";


Vue.use(Vuex)
const USER_KEY='toutiao-user'
export default new Vuex.Store({

    state:{
        user:getItem(USER_KEY)
    },
    mutations:{
        setUser(state,data){
            state.user=data
            // window.localStorage.setItem('user',JSON.stringify(data))
            setItem(USER_KEY,state.user)    //封装的方法
        }
    },
    actions:{

    },
    modules:{

    }
})


